package com.cloudwise.controller;

import com.cloudwise.entity.ReturnBean;
import com.cloudwise.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

/**
 * @author ：Teacher陈
 * @date ：Created in 2020/12/25 10:23
 * @description：统计业务控制器
 * @modified By：
 * @version: 1.0
 */
@Controller
@RequestMapping("count")
public class CountController  extends  BaseController {

    @Autowired
    private UserService userService;

    /**
     * @create by: Teacher陈
     * @description: 跳转到默认统计页面（默认的首页）
     * @create time: 2020/12/25 10:23
     * @return
     */
    @GetMapping("toShowCount")
    public ModelAndView toShowCount(ModelAndView modelAndView){
        modelAndView.setViewName("count/defaultCount");
        return modelAndView;
    }
    
    /**
     * @create by: Teacher陈
     * @description: 测试统计，统计每个部门的员工数量
     * @create time: 2020/12/25 11:27
     * @return
     */
    @GetMapping("getCountUserByDept")
    @ResponseBody
    public ReturnBean getCountUserByDept(){
        Map countUserByDept = userService.getCountUserByDept();
        return returnSuccess(countUserByDept);
    }
}
